1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.48">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0000bf}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Helvetica
; min-height: 11.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0000bf}
20 span
.s1
{font: 18.0px Helvetica
}
21 span
.s2
{color: #000000}
22 span
.s3
{color: #0000bf}
23 span
.s4
{color: #0000bf}
24 span
.s5
{color: #0000bf}
25 span
.s6
{color: #0000bf}
26 span
.s7
{color: #0000bf}
27 span
.s8
{color: #bf0000}
28 span
.s9
{color: #606060}
29 span
.Apple-tab-span
{white-space:pre
}
33 <p class=
"p1"><span class=
"s1"><b>TDuty
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>demand results as trigger from demand rate ugens
</b></p>
34 <p class=
"p2"><br></p>
35 <p class=
"p3"><span class=
"s2"><b>Inherits from:
</b><a href=
"../../../Core/Object.html"><span class=
"s3"><b>Object
</b></span></a></span><span class=
"s4"><b> :
</b><a href=
"../../../Core/Kernel/AbstractFunction.html"><span class=
"s5"><b>AbstractFunction
</b></span></a><b> :
</b><a href=
"../../UGen.html"><span class=
"s3"><b>UGen
</b></span></a><b> :
</b><a href=
"Duty.html"><span class=
"s3"><b>Duty
</b></span></a></span></p>
36 <p class=
"p2"><br></p>
37 <p class=
"p4"><b>TDuty.ar(dur, reset,
<span class=
"Apple-converted-space"> </span>level, doneAction)
</b></p>
38 <p class=
"p4"><b>TDuty.kr(dur, reset,
<span class=
"Apple-converted-space"> </span>level, doneAction)
</b></p>
39 <p class=
"p2"><br></p>
40 <p class=
"p5"><br></p>
41 <p class=
"p4">(Note that for sc
3.2, TDuty has changed. For the old behaviour, use
<b>TDuty_old
</b>.)
<span class=
"Apple-converted-space"> </span></p>
42 <p class=
"p5"><br></p>
43 <p class=
"p4">A value is demanded each ugen in the list and output
<span class=
"Apple-converted-space"> </span>as a trigger according to a stream of duration values.
<span class=
"Apple-converted-space"> </span></p>
44 <p class=
"p4">The unit generators in the list should be 'demand' rate.
</p>
45 <p class=
"p2"><br></p>
46 <p class=
"p4">When there is a trigger at the reset input, the demand rate ugens in the list and the duration are reset.
</p>
47 <p class=
"p4">The reset input may also be a demand ugen, providing a stream of reset times.
</p>
48 <p class=
"p2"><br></p>
49 <p class=
"p4">see also:
<a href=
"Demand.html"><span class=
"s4">Demand
</span></a><span class=
"s4">,
<a href=
"Duty.html"><span class=
"s6">Duty
</span></a></span></p>
50 <p class=
"p2"><br></p>
51 <p class=
"p4"><b>dur
<span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>time values. Can be a demand ugen or any signal.
<span class=
"Apple-converted-space"> </span></p>
52 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The next trigger value is acquired after the duration provided by the last time value.
</p>
53 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
54 <p class=
"p4"><b>reset
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>trigger or reset time values. Resets the list of ugens and the duration ugen when triggered.
</p>
55 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The reset input may also be a demand ugen, providing a stream of reset times.
</p>
56 <p class=
"p6"><br></p>
57 <p class=
"p5"><br></p>
58 <p class=
"p4"><b>level
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span>demand ugen providing the output values.
</p>
59 <p class=
"p2"><br></p>
60 <p class=
"p2"><br></p>
61 <p class=
"p4"><b>doneAction
</b><span class=
"Apple-tab-span"> </span>a doneAction that is evaluated when the duration stream ends.
</p>
62 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>See
<a href=
"../Envelopes/UGen-doneActions.html"><span class=
"s7">UGen-doneActions
</span></a> for more detail.
</p>
63 <p class=
"p2"><br></p>
64 <p class=
"p6"><br></p>
65 <p class=
"p5"><br></p>
66 <p class=
"p5"><br></p>
67 <p class=
"p5"><br></p>
68 <p class=
"p5"><br></p>
69 <p class=
"p7">// examples
</p>
70 <p class=
"p5"><br></p>
71 <p class=
"p8">s.boot;
</p>
72 <p class=
"p5"><br></p>
73 <p class=
"p5"><br></p>
74 <p class=
"p7">// play a little rhythm
</p>
75 <p class=
"p5"><br></p>
76 <p class=
"p8">{
<span class=
"s4">TDuty
</span>.ar(
<span class=
"s4">Dseq
</span>([
0.1,
0.2,
0.4,
0.3],
<span class=
"s4">inf
</span>)) }.play;
<span class=
"s8">// demand ugen as durations
</span></p>
77 <p class=
"p5"><br></p>
78 <p class=
"p5"><br></p>
79 <p class=
"p5"><br></p>
80 <p class=
"p7">// amplitude changes
</p>
82 <p class=
"p8"><span class=
"Apple-tab-span"> </span>{
</p>
83 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> trig;
</p>
84 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>trig =
<span class=
"s4">TDuty
</span>.ar(
</p>
85 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Dseq
</span>([
0.1,
0.2,
0.4,
0.3],
<span class=
"s4">inf
</span>),
<span class=
"s8">// demand ugen as durations
</span></p>
86 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
<span class=
"Apple-converted-space"> </span></p>
87 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Dseq
</span>([
0.1,
0.4,
0.01,
0.5,
1.0],
<span class=
"s4">inf
</span>)
<span class=
"s8">// demand ugen as amplitude
</span></p>
88 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
<span class=
"Apple-converted-space"> </span></p>
89 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Ringz
</span>.ar(trig,
1000,
0.1)
</p>
90 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
91 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}.play;
</p>
93 <p class=
"p5"><br></p>
95 <p class=
"p8"><span class=
"Apple-tab-span"> </span>{
</p>
96 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> trig;
</p>
97 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>trig =
<span class=
"s4">TDuty
</span>.ar(
</p>
98 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s4">MouseX
</span><span class=
"s2">.kr(
0.001,
2,
1),
</span>// control rate ugen as durations
</p>
99 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
<span class=
"Apple-converted-space"> </span></p>
100 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Dseq
</span>([
0.1,
0.4,
0.01,
0.5,
1.0],
<span class=
"s4">inf
</span>)
</p>
101 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
<span class=
"Apple-converted-space"> </span></p>
102 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Ringz
</span>.ar(trig,
1000,
0.1)
</p>
103 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
104 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}.play;
</p>
106 <p class=
"p5"><br></p>
107 <p class=
"p5"><br></p>
108 <p class=
"p5"><br></p>
109 <p class=
"p5"><br></p>
110 <p class=
"p7">// demand ugen as audio oscillator
</p>
111 <p class=
"p5"><br></p>
113 <p class=
"p8"><span class=
"Apple-tab-span"> </span>{
</p>
114 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> a, trig, n=
5, m=
64;
</p>
115 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a = {
</p>
116 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> x;
</p>
117 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>x = {
0.2.rand2 } ! m;
</p>
118 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>x = x ++ ({
<span class=
"Apple-converted-space"> </span><span class=
"s4">Drand
</span>({
0.2.rand2 } ! n) } ! m.rand);
</p>
119 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Dseq
</span>(x.scramble,
<span class=
"s4">inf
</span>)
</p>
120 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>} ! n;
</p>
121 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>trig =
<span class=
"s4">TDuty
</span>.ar(
</p>
122 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">MouseX
</span>.kr(
1,
2048,
1) *
<span class=
"s4">SampleDur
</span>.ir * [
1,
1.02],
</p>
123 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
</p>
124 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Dswitch1
</span>(a,
<span class=
"s4">MouseY
</span>.kr(
0, n-
1))
</p>
125 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
126 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Ringz
</span>.ar(trig,
1000,
0.01)
</p>
127 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
128 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}.play;
</p>
130 <p class=
"p5"><br></p>
131 <p class=
"p5"><br></p>
132 <p class=
"p7">// single impulses
</p>
133 <p class=
"p5"><br></p>
135 <p class=
"p8"><span class=
"s4">SynthDef
</span>(
<span class=
"s9">"delta_demand"</span>, { arg amp=
0.5, out;
</p>
136 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s4">OffsetOut
</span>.ar(out,
</p>
137 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">TDuty
</span>.ar(
<span class=
"s4">Dseq
</span>([
0]),
0, amp,
2)
</p>
138 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
139 <p class=
"p8">}).send(s);
</p>
141 <p class=
"p5"><br></p>
142 <p class=
"p8">fork {
10.do { s.sendBundle(
0.2, [
<span class=
"s9">"/s_new"</span>,
<span class=
"s9">"delta_demand"</span>, -
1]);
1.0.rand.wait } };
</p>
143 <p class=
"p5"><br></p>
144 <p class=
"p5"><br></p>
145 <p class=
"p7">// chain of impulses
</p>
147 <p class=
"p9"><span class=
"s4">SynthDef
</span><span class=
"s2">(
</span>"delta_demand2"<span class=
"s2">, {
</span></p>
148 <p class=
"p10"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>OffsetOut
<span class=
"s2">.ar(
0,
</span></p>
149 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">TDuty
</span>.ar(
<span class=
"s4">Dgeom
</span>(
0.05,
0.9,
20),
0,
0.5,
2)
</p>
150 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
151 <p class=
"p8">}).send(s);
</p>
153 <p class=
"p5"><br></p>
154 <p class=
"p8">fork {
10.do { s.sendBundle(
0.2, [
<span class=
"s9">"/s_new"</span>,
<span class=
"s9">"delta_demand2"</span>, -
1]);
1.0.rand.wait } };
</p>
155 <p class=
"p5"><br></p>
156 <p class=
"p5"><br></p>
157 <p class=
"p5"><br></p>
158 <p class=
"p7">// multichannel expansion
</p>
159 <p class=
"p5"><br></p>
161 <p class=
"p8"><span class=
"Apple-tab-span"> </span>{
</p>
162 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> t;
</p>
163 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>t =
<span class=
"s4">TDuty
</span>.ar(
</p>
164 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Drand
</span>([
<span class=
"s4">Dgeom
</span>(
0.1,
0.8,
20),
1,
2],
<span class=
"s4">inf
</span>) !
2,
</p>
165 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
<span class=
"Apple-converted-space"> </span></p>
166 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
<span class=
"s4">Drand
</span>({
1.0.rand } !
8,
<span class=
"s4">inf
</span>),
<span class=
"s4">Dseq
</span>({
1.0.rand } !
8,
<span class=
"s4">inf
</span>)] *
2</p>
167 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
<span class=
"Apple-converted-space"> </span></p>
168 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>x =
<span class=
"s4">Ringz
</span>.ar(t, [
400,
700],
0.1) *
0.1;
</p>
169 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
170 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}.play;
</p>
172 <p class=
"p5"><br></p>
173 <p class=
"p5"><br></p>